<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%><%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<tiles:insertDefinition name="layout">
	<tiles:putAttribute name="head">
		<script type="text/javascript">
	    $(function() {
		$("#datepicker").datepicker({
		    showWeek : true,
		    firstDay : 1,
		    dateFormat : 'yy-mm-dd',
		    showOtherMonths : true,
		    selectOtherMonths : true,
		    onSelect : function(date, source) {
			$("form").submit();
		    }
		});

		$(".confirm").confirmDialog(function(data) {
		    helper.showMsg(data, {
			okHandler : function() {
			    location = "../log/viewLogByTime?id=" + data.id;
			}
		    });
		});

		$(".scroll").click(function() {
		    var t = $(this).attr("href");
		    $("html,body").animate({
			scrollTop : $(t).offset().top - 60
		    }, "fast");
		});

		$(".dialog").frameDialog({
		    width : 800,
		    height : 500,
		    close : function() {
			if (art.dialog.data("success")) {
			    location.reload();
			}
		    }
		});
	    });
	</script>
	</tiles:putAttribute>
	<tiles:putAttribute name="mainBody">
		<ul class="breadcrumb">
			<li><s:url action="listStudent" namespace="/student" id="listStudent">
				</s:url> <a href="${listStudent}">学员列表</a> <span class="divider">/</span></li>
			<li><s:url action="viewLogByTime" namespace="/log" id="viewLogByTime">
					<s:param name="id" value="#student.id"></s:param>
				</s:url> <a href="${viewLogByTime}">学员日志</a> <span class="divider">/</span></li>
			<li class="active">试听课程</li>
		</ul>
		<form class="form-horizontal">
			<input name="studentId" type="hidden" value="${student.id}" />
			<fieldset>
				<legend>
					为 <strong>${student.name}</strong> 选择试听课程
				</legend>
				<div class="control-group">
					<div class="control-label">日期选择</div>
					<div class="controls">
						<a href="?startDate=${preDate}&studentId=${studentId}" class="btn">
							<i class="icon-chevron-left"></i>
						</a>
						<input type="text" name="startDate" id="datepicker" value="${currentDate}" />
						<a href="?startDate=${nextDate}&studentId=${studentId}" class="btn">
							<i class="icon-chevron-right"></i>
						</a>
						当日共 <strong><s:property value="#reports.size" /> </strong> 节课
					</div>
				</div>
			</fieldset>
		</form>
		<ul class="nav nav-tabs">
			<li class="active"><a href="#morning" class="scroll">Morning</a></li>
			<li><a href="#afternoon" class="scroll">Afternoon</a></li>
			<li><a href="#evening" class="scroll">Evening</a></li>
		</ul>
		<table class="table">
			<thead>
				<tr>
					<th>Time</th>
					<th>Lesson</th>
					<th>Listeners</th>
					<th>Teacher</th>
					<th>Classroom</th>
					<th>Type</th>
					<th>Action</th>
				</tr>
			</thead>
			<tbody id="selectable">
				<s:iterator value="reports" var="report">
					<tr class="${report.lesson.courseType.cssClass}">
						<td><s:if test="isMorning(beginTime)">
								<a id="morning"></a>
							</s:if> <s:elseif test="isAfternoon(lesson.beginTime)">
								<a id="afternoon"></a>
							</s:elseif> <s:elseif test="isEvening(lesson.beginTime)">
								<a id="evening"></a>
							</s:elseif> ${report.lesson.timespan}</td>
						<td><s:url action="listListener" namespace="/lesson" id="listListener">
								<s:param name="id" value="lesson.id"></s:param>
							</s:url> <a href="${listListener}">${report.lesson.name}</a> <s:if test="canceled">
								<span class="label">已取消</span>
							</s:if></td>
						<td>${report.count}</td>
						<td><s:iterator value="lesson.teachings" var="teaching" status="status">
								<s:url action="listTeacherLesson" namespace="/schedule" id="listTeacherLesson">
									<s:param name="teacherId" value="teacher.id"></s:param>
									<s:param name="startDate" value="#startDate"></s:param>
									<s:param name="endDate" value="#endDate"></s:param>
								</s:url>
								<a href="${listTeacherLesson}">${teaching.teacher.name}</a>
								<s:if test="!status.last">,</s:if>
							</s:iterator></td>
						<td><s:url namespace="/schedule" action="listClassroomLesson" id="listClassroomLesson">
								<s:param name="classroomId" value="lesson.classroom.id"></s:param>
								<s:param name="startDate" value="#startDate"></s:param>
								<s:param name="endDate" value="#endDate"></s:param>
							</s:url> <a href="${listClassroomLesson}">${lesson.classroom.name}</a></td>
						<td><s:url action="listTypeLesson" namespace="/schedule" id="listTypeLesson">
								<s:param name="courseTypeId" value="lesson.courseType.id"></s:param>
								<s:param name="startDate" value="#startDate"></s:param>
								<s:param name="endDate" value="#endDate"></s:param>
							</s:url> <a href="${listTypeLesson }"> ${report.lesson.courseType.name}</a></td>
						<td><s:url action="doOrderAuditionLesson" namespace="/orderlesson" id="doOrderAuditionLesson">
								<s:param name="studentId" value="#student.id"></s:param>
								<s:param name="lessonId" value="lesson.id"></s:param>
							</s:url> <a href="${doOrderAuditionLesson}" title="选择该课程" class="confirm btn">选择该课程</a></td>
					</tr>
				</s:iterator>
			</tbody>
			<tfoot></tfoot>
		</table>
	</tiles:putAttribute>
</tiles:insertDefinition>